package com.hqyj.system.service.impl;

import com.hqyj.system.mapper.RoleMapper;
import com.hqyj.system.mapper.UserMapper;
import com.hqyj.system.model.Role;
import com.hqyj.system.model.User;
import com.hqyj.system.service.RoleService;
import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.io.IOException;
import java.io.InputStream;
import java.util.List;

/**
 * @ClassName RoleServiceImpl
 * @Description
 * @Author zlf
 * @Date 2021/9/14 10:16
 * @Version 1.0
 **/
@Service
public class RoleServiceImpl implements RoleService {
    @Autowired
    private RoleMapper roleMapper;

    @Override
    public List<Role> queryAllRole() {
        return roleMapper.queryAllRole();
    }

    @Override
    public int addRoleByRole(Role role) {
        return roleMapper.insertSelective(role);
    }

    @Override
    public int deleteRoleByRoleId(int roleId) {
        return roleMapper.deleteByPrimaryKey(roleId);
    }

    @Override
    public Role queryRoleByRoleId(int roleId) {
        return roleMapper.selectByPrimaryKey(roleId);
    }

    @Override
    public int updateRoleByRole(Role role) {
        return roleMapper.updateByPrimaryKeySelective(role);
    }

    @Override
    public Role query_xz_roleByUserId(int userId) {
        return roleMapper.query_xz_roleByUserId(userId);
    }

    @Override
    public List<Role> queryRoleByUserId(int userId) {
        return roleMapper.queryRoleByUserId(userId);
    }
}
